package com.wanxin.wb.common.support;



import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.reflect.MethodSignature;

import java.lang.reflect.Method;

/**
 * <B>Description:</B> 拦截并设置ServiceNumber <br>
 * <B>Create on:</B> 2016/9/19<br>
 *
 * @author 
 * @version 1.0
 */
public class ServiceNumberHandler {
    /**
     * <B>Description:</B> 处理ServiceNumber <br>
     * <B>Create on:</B> 2016/9/19 20:59 <br>
     *
     * @author 
     * @param jp
     * @return
     */
    public void before(JoinPoint jp) throws Throwable {
        if(jp.getSignature() instanceof MethodSignature){
            MethodSignature methodSignature = (MethodSignature) jp.getSignature();
            Method method = methodSignature.getMethod();
            RestServiceNum anno = method.getAnnotation(RestServiceNum.class);
            if(anno!=null){
                String serviceNum = anno.value();
                ServiceNumberSupport.setServiceNumber(serviceNum);
            }
        }
    }
}
